package easy

import "workspace/node"

func IncreasingBST(root *node.TreeNode) *node.TreeNode {
	vals := []int{}
	var inorder func(*node.TreeNode)
	inorder = func(node *node.TreeNode) {
		if node != nil {
			inorder(node.Left)
			vals = append(vals, node.Val)
			inorder(node.Right)
		}
	}
	inorder(root)
	dummyNode := &node.TreeNode{}
	curNode := dummyNode
	for _, val := range vals {
		curNode.Right = &node.TreeNode{Val: val}
		curNode = curNode.Right
	}
	return dummyNode.Right
}
